﻿using System;
using System.ComponentModel;

namespace Bonobo.Irc
{
    internal static class EventHandlerListExtensions
    {
        public static void InvokeEvent(this EventHandlerList list, Object key, Object sender, EventArgs e)
        {
            var handler = (EventHandler)(list[key]);

            if (handler != null)
            {
                handler(sender, e);
            }
        }

        public static void InvokeEvent<TArgs>(this EventHandlerList list, Object key, Object sender, TArgs e) where TArgs : EventArgs
        {
            var handler = (EventHandler<TArgs>)(list[key]);

            if (handler != null)
            {
                handler(sender, e);
            }
        }
    }
}
